Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.registerToken = exports.responseResolveIfNeedLogin = exports.checkIfInTabBar = exports.checkIfNeedSignin = void 0;

var _apiCode = _interopRequireDefault(require("../../utils/api-code")), _user = _interopRequireDefault(require("../../utils/user"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var tabBarPagePath = [ "pages/card/index/index", "pages/contacts/index/index", "pages/mine/mine" ], checkIfNeedSignin = function(e) {
    return [ _apiCode.default.TOKEN_INVALID, _apiCode.default.TOKEN_EXPIRY ].includes(e);
};

exports.checkIfNeedSignin = checkIfNeedSignin;

var checkIfInTabBar = function() {
    var e = getCurrentPages(), r = e[e.length - 1].route;
    return tabBarPagePath.includes(r);
};

exports.checkIfInTabBar = checkIfInTabBar;

var responseResolveIfNeedLogin = function(e) {
    return checkIfNeedSignin(e.code) ? Promise.reject(e) : Promise.resolve(e);
};

exports.responseResolveIfNeedLogin = responseResolveIfNeedLogin;

var registerToken = function(e) {
    var r = e.detail;
    return /fail/.test(r.errMsg) ? Promise.reject(r) : _user.default.registerToken(r);
};

exports.registerToken = registerToken;